{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 文件加载器测试\n",
    "\n",
    "本 notebook 用于测试 PDF, PPT, Excel, Word 四种格式文件的加载功能。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from autocoder.utils.rest import HttpDoc\n",
    "import byzerllm\n",
    "\n",
    "# 初始化 LLM 实例\n",
    "llm = byzerllm.ByzerLLM()\n",
    "\n",
    "# 测试文件路径\n",
    "test_files = {\n",
    "    \"pdf\": \"tests/data/sample.pdf\",\n",
    "    \"ppt\": \"tests/data/sample.pptx\",\n",
    "    \"excel\": \"tests/data/sample.xlsx\",\n",
    "    \"docx\": \"tests/data/sample.docx\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试 PDF 文件\n",
    "pdf_doc = HttpDoc(None, llm, [test_files[\"pdf\"]])\n",
    "pdf_content = pdf_doc.crawl_urls()\n",
    "print(\"PDF Content:\")\n",
    "print(pdf_content[0].source_code[:500])  # 打印前500个字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试 PPT 文件\n",
    "ppt_doc = HttpDoc(None, llm, [test_files[\"ppt\"]])\n",
    "ppt_content = ppt_doc.crawl_urls()\n",
    "print(\"PPT Content:\")\n",
    "print(ppt_content[0].source_code[:500])  # 打印前500个字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试 Excel 文件\n",
    "excel_doc = HttpDoc(None, llm, [test_files[\"excel\"]])\n",
    "excel_content = excel_doc.crawl_urls()\n",
    "print(\"Excel Content:\")\n",
    "print(excel_content[0].source_code[:500])  # 打印前500个字符"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 测试 Word 文件\n",
    "docx_doc = HttpDoc(None, llm, [test_files[\"docx\"]])\n",
    "docx_content = docx_doc.crawl_urls()\n",
    "print(\"Word Content:\")\n",
    "print(docx_content[0].source_code[:500])  # 打印前500个字符"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}